package com.acp.controller;

import com.acp.param.DcsGroupParam;
import com.acp.result.PageResult;
import com.acp.result.ResultInfo;
import com.acp.service.DcsGroupService;
import com.acp.util.BeanValidator;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import javax.annotation.Resource;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.controller.construction
 * @Description: 小组管理
 * @author: 张星亮
 * @date: 2019/4/5
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */

@Controller
@RequestMapping("/element")
public class DcsGroupController {

    @Resource
    private DcsGroupService dcsGroupService;

    /**
     * 新增小组
     *
     * @param dcsGroupParam
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     * @throws Exception
     */
    @PostMapping("/addGisElement")
    @ResponseBody
    public ResultInfo addGisElement(@RequestBody DcsGroupParam dcsGroupParam) throws Exception {
        BeanValidator.check(dcsGroupParam);
        return dcsGroupService.addDcsGroup(dcsGroupParam);
    }

    /**
     * 查询所有小组信息
     *
     * @param name
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/queryGisElementList")
    @ResponseBody
    public PageResult queryGisElementList(@RequestBody(required = false) String name) {
        PageResult pageResult = dcsGroupService.queryDcsGroupList(name);
        return pageResult;
    }

    /**
     * 根据主键删除小组
     *
     * @param list
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @PostMapping("/deleteGisElementById")
    @ResponseBody
    public ResultInfo deleteGisElementById(@RequestBody List<DcsGroupParam> list) {
        ResultInfo resultInfo = dcsGroupService.deleteDcsGroupById(list);
        return resultInfo;
    }

    /**
     * 编辑小组
     *
     * @param dcsGroupParam
     * @return ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     * @throws Exception
     */
    @PostMapping("/editGisElement")
    @ResponseBody
    public ResultInfo editGisElement(@RequestBody DcsGroupParam dcsGroupParam) throws Exception {
        BeanValidator.check(dcsGroupParam);
        return dcsGroupService.editDcsGroup(dcsGroupParam);
    }

}
